package org.llc.flink.study.example

object AssignoperDemo01 {

  def main(args: Array[String]): Unit = {
    var num = 2
    // 左移2位后赋值
    num <<= 2
    println(num)
    num >>= 3
    println(num) //1

    // 在scala 中支持代码块，返回值
    val res = {
      if (num > 1) "hello scala" else 100
    }
    println("res = " + res) //100

    swap()
    exchange()

  }


  /**
    * 不使用第三个值交换两个数的值
    */
  def swap(): Unit = {
    var a = 10
    var b = 20
    a = a + b
    b = a - b
    a = a - b
    println("a =" + a)
    println("b =" + b)
  }

  /**
    * 位运算
    */
  def exchange(): Unit = {
    var a = 10
    var b = 20
    a = a ^ b
    println(a)
    b = a ^ b
    println(b)
    a = a ^ b
    println(a)
  }
}
